import { getDictionaryApi } from '@/api/Device-all/Device-view'
// 字典查询
const getDictionary = async (name) => {
  const res = await getDictionaryApi(name)
  return res.data.list
}

const InternalValidator = [
  {
    componentName: 'NtSwitch',
    span: 24,
    label: '是否非空',
    prop: 'required',
    rules: [
      {
        required: true,
        message: '请选择是否非空',
        trigger: 'change'
      }
    ]
  },
  {
    componentName: 'NtInput',
    span: 12,
    label: '最小长度',
    prop: 'minLength'
  },
  {
    componentName: 'NtInput',
    span: 12,
    label: '最大长度',
    prop: 'maxLength'
  },
  {
    componentName: 'NtInput',
    span: 12,
    label: '最小数值',
    prop: 'minRange'
  },
  {
    componentName: 'NtInput',
    span: 12,
    label: '最大数值',
    prop: 'maxRange'
  },
  {
    componentName: 'NtInput',
    span: 24,
    label: '正则表达式',
    prop: 'regexp'
  },
  {
    componentName: 'NtInput',
    span: 24,
    label: '提示信息',
    prop: 'promptMessage'
  }
]

const CustomValidator = [
  {
    componentName: 'NtSelect',
    span: 24,
    label: '自定义校验',
    prop: 'customValidatorCode',
    selectList: () => getDictionary('VomCustomValidator'),
    rules: [
      {
        required: true,
        message: '请选择自定义校验',
        trigger: 'change'
      }
    ]
  }
]
export { InternalValidator, CustomValidator }
